package Terrains;

public abstract class Structure extends Terrain{
	
	/** The amount of capture points the structure has */
	private int capturePoints;
	/** The number of the player that owns this structure */
	private int player;
	
	
	
	/**
	 * Constructor
	 * @param defenseMultiplier - the defense multiplier
	 */
	public Structure(int row, int col, double defenseMultiplier){
		super(row,col,defenseMultiplier);
		capturePoints = 200;
		player = 0;
	}

	/**
	 * Constructor
	 * @param defenseMultiplier - the defense multiplier
	 * @param player - the owner of the structure
	 */
	public Structure(int row, int col, double defenseMultiplier, int player){
		super(row,col,defenseMultiplier);
		capturePoints = 200;
		this.player = player;
	}

	/**
	 * This method attempts to capture a structure by </br>
	 * a certain amount. The amount should be the health </br>
	 * of the unit occupying the structure.
	 * @param amount - the health of the unit
	 * @return true if it has been captured </br>
	 * 			false if it has not
	 */
	public boolean capture(int amount){
		capturePoints -= amount;
		return (capturePoints <= 0);
	}
	
	/**
	 * Returns whether or not this building has been captured
	 * @return whether or not it is capped;
	 */
	public boolean isCapped(){
		return (capturePoints <= 0);
	}
	
	/**
	 * Resets the capture points back to the default</br>
	 * of 200 points
	 */
	public void resetCapturePoints(){
		capturePoints = 200;
	}
	
	/**
	 * 
	 * @return - how many capture points are left
	 */
	public int getCapturePoints(){
		if (capturePoints < 0)
			return 0;
		return capturePoints;
	}

	/**
	 * Returns the number of the player who owns this </br>
	 * structure.
	 * @return the player
	 */
	public int getPlayer(){
		return player;
	}
	
	/**
	 * Sets the owner of this structure
	 * 0 is neutral
	 * @param newPlayer - the number of the new player;
	 */
	public void setPlayer(int newPlayer){
		player = newPlayer;
	}
	
}
